#! /usr/bin/env node

const fs=require('fs')
const path=require('path')

const program=require('commander')
const inquirer=require('inquirer')

// 9、用自定义node命令行指令在项目目录下创建src目录 8：52
program.command('create-src')
    .action(()=>{
        fs.mkdirSync('src')
    })
// 10、在src目录下用指令创建index.html  
program.command('create-html')
    .action(()=>{
        fs.writeFileSync("index.html",'hello!!','utf-8')
    })


const option=[{
    type:'input',
    message:'name:',
    name:'name',
    default:'src'
},{
    type:'input',
    message:'version',
    name:'version'
},{
    type:"input",
    message:'main',
    name:"main",
    default:'app.js'
}]
program.command('real-init')
    .action(()=>{
        inquirer.prompt(option).then(res=>{
            console.log(res)
            fs.writeFileSync('package.json',JSON.stringify(res),'utf-8')
        })
    })


program.parse(process.argv)